<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>Customer</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="/lib/layui-v2.6.3/css/layui.css" media="all">
    <link rel="stylesheet" href="/css/public.css" media="all">
</head>
<body>
<div class="layuimini-container" id="app">
    <div class="layuimini-main">
        <fieldset class="table-search-fieldset">
            <legend>玩家LTU</legend>
            <div style="margin: 10px 10px 10px 10px">
                <form class="layui-form layui-form-pane" action="" lay-filter="table-search">

                    <div class="layui-form-item">
                        <div class="layui-inline">
                            <label class="layui-form-label">选择区服:</label>
                            <div class="layui-input-inline">
                                <select name="gameArea" class="layui-select">
                                    <option v-for="(item,index) in services" :value="item.server_id" :selected="index==0">{{item.name}}</option>
                                </select>
                            </div>
                        </div>
                        <div class="layui-inline">
                            <label class="layui-form-label">注册时间</label>
                            <div class="layui-input-inline">
                                <input type="text" name="createDateBegin" id="createTime0"
                                       placeholder="开始时间" autocomplete="off" class="layui-input" />
                                <input type="text" name="createDateEnd" id="createTime1"
                                       placeholder="截止时间" autocomplete="off" class="layui-input" />
                            </div>
                        </div>
                        <div class="layui-inline">
                            <button type="submit" class="layui-btn layui-btn-primary" lay-submit lay-filter="data-search-btn"><i class="layui-icon"></i>搜 索</button>
                        </div>
                    </div>
                </form>
            </div>
        </fieldset>
        <table class="layui-hide" id="currentTableId" lay-filter="currentTableFilter"></table>
    </div>
</div>

<style>
    span.percentage{
        color:#03a9f4;
    }
</style>
<script src="/lib/layui-v2.6.3/layui.js" charset="utf-8"></script>
<script src="/js/common.js?v=5" charset="utf-8"></script>
<script>

    function calculatePercentage(num, total) { //计算2个数的百分比
        if (total === 0) {
            return 0;
        }
        const percentage = (num / total) * 100;
        return parseFloat(percentage.toFixed(2));
    }

    new Vue({
        el: "#app",
        data: {
            services:JSON.parse(localStorage.getItem('services')),
        },
        mounted: function () {
            layui.use(['form', 'table'], function () {
                var $ = layui.jquery,
                    form = layui.form,
                    table = layui.table,
                    laydate=layui.laydate;
                laydate.render({
                    elem: '#createTime0',
                    value: getYmd(0)
                });
                laydate.render({
                    elem: '#createTime1',
                    value: getYmd(1)
                })

                var liucunlv = function(row,field){
                    var all = row.reg_num;
                    var thisDayLiucun = row[field];
                    if (all === 0 || thisDayLiucun===0 ) return '-';
                    console.log(thisDayLiucun , all)
                    return thisDayLiucun ;
                }
                var reload = function(){
                    table.render({
                        where:form.val('table-search'),
                        elem: '#currentTableId',
                        url: '/admin/memberLtu/paginate',
                        defaultToolbar: ['filter', 'print' ],
                        cols: [[
                            {type: "checkbox", width: 50},
                            {field: 'ymd', title:'日期',width:160 },
                            {field: 'reg_num', title:'注册人数' },
                            {field: 'day_1', title:'第1日LTU'},
                            {field: 'day_2_num', title:'第2日LTU'},
                            {field: 'day_3_num', title:'第3日LTU' },
                            {field: 'day_4_num', title:'第4日LTU' },
                            {field: 'day_5_num', title:'第5日LTU'},
                            {field: 'day_6_num', title:'第6日LTU' },
                            {field: 'day_7_num', title:'第7日LTU'},
                            {field: 'day_15_num', title:'第15日LTU' },
                            {field: 'day_30_num', title:'第30日LTU' },
                            {field: 'day_45_num', title:'第45日LTU' },
                            {field: 'day_60_num', title:'第60日LTU' },
                            {field: 'day_90_num', title:'第90日LTU' },
                        ]],
                        limits: [10, 15, 20, 25, 50, 100],
                        limit: 15,
                        page: true,
                        skin: 'line'
                    });
                }
                reload();

                form.on('submit(data-search-btn)', function () {
                    reload();
                    return false;
                });


            });
        }
    })
</script>
</body>
</html>